/**
 * 
 */
package com.thor.palmmall.rest.brand.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.brand.ABrandQueryParam;
import com.thor.palmmall.spi.brand.SBrandQueryParam;

/**
 * @author Captain
 *
 * @since 1.0
 */
public class SBrandQueryParamConverter implements Converter<ABrandQueryParam, SBrandQueryParam> {

  public static SBrandQueryParamConverter getInstance() {
    if (instance == null)
      instance = new SBrandQueryParamConverter();
    return instance;
  }

  private static SBrandQueryParamConverter instance;

  private SBrandQueryParamConverter() {
  }

  @Override
  public SBrandQueryParam convert(ABrandQueryParam source) {
    if (source == null) {
      return null;
    }
    SBrandQueryParam target = new SBrandQueryParam();
    target.setKeyword(source.getKeyword());
    target.setOrder(source.getOrder());
    target.setPage(source.getPage());
    target.setPageSize(source.getPageSize());
    target.setStores(new ArrayList<String>());
    if (source.getStores() != null)
      target.getStores().addAll(source.getStores());
    target.setBizTypeUuid(source.getBizTypeUuid());
    target.setBrandGrade(source.getBrandGrade());
    target.setStates(new ArrayList<String>());
    if (source.getStates() != null)
      target.getStates().addAll(source.getStates());
    return target;
  }

}
